<?php
/**
 * Created by PhpStorm.
 * User: lzh 9157374
 * Date: 2018/6/4
 * Time: 下午5:25
 */
namespace Core\common;
class AesEncrypt
{
    const AES_KEY = "qq3217834abcdefg"; //16位
    const AES_IV  = "1234567890123456"; //16位

    public static function decryptString($str)
    {
        $decrypted = openssl_decrypt(base64_decode($str), 'aes-128-cbc', self::AES_KEY, OPENSSL_RAW_DATA, self::AES_IV);
        return $decrypted;
    }

    public static function encryptString($plain_text)
    {
        $encrypted_data = openssl_encrypt($plain_text, 'aes-128-cbc', self::AES_KEY, OPENSSL_RAW_DATA, self::AES_IV);

        return base64_encode($encrypted_data);
    }
}